package a_exception.e_try;

public class Demo {
    public static void main(String[] args) {
//        //1.制造运行时异常
//        int[] arr = {1,2,3,4};
//        //System.out.println(arr[4]);
//
//        //2.空指针异常
//        String[] sArr = new String[3];//null.null.null
//        //System.out.println(sArr[0].length());
//
//        //3.类型转换异常
//        Object o = new String();
//        Integer i = (Integer) o;
//        //System.out.println(i);


        try {
            Demo01Array.m1();
            Demo02Null.m2();
            Demo03ClassCast.m3();
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组下标越界了...");
        } catch (NullPointerException e){
            System.out.println("空指针异常");
        } catch (ClassCastException e){
            System.out.println("类型转换异常");
        } catch (RuntimeException e){
            System.out.println("虽然可以精简代码,但是没办法具体指导是什么问题");
        }
    }


}
